package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController

public class OrderHystrixController {

    @Resource
    private PaymentService paymentHystrixService;

    @GetMapping("/consumer/payment/hystrix/ok/{id}")
    public String paymentInfo_ok(@PathVariable("id") Integer id){

    return  paymentHystrixService.paymentInfo_ok(id);

    }

    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
//    @HystrixCommand(fallbackMethod = "timeOutFallbackMethod",commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "2000")
//    })

    public String paymentInfo_timeout(@PathVariable("id")  Integer id){

        return paymentHystrixService.paymentInfo_timeout(id);

    }

    //使用了全局的 降级处理
//  public String  timeOutFallbackMethod(Integer id){
//
//      return  "线程池： "+Thread.currentThread().getName()+"我是消费者80  支付系统繁忙或者出错请稍后再试,id: "+id;
//  }
//
//
//  //下面是全局的fAllback 方法
//    public String payment_Global_FallBackMethod(){
//
//        return "Global 异常处理信息，请稍后再试。";
//
//    }



}
